#! python
# -*- coding: utf-8 -*-
"""
@File Name: 组件构建器_widgets.py
@Author: LT
@Date: 2021/10/27 11:18
# -----------------------------------------------------------------------------------------------------
@Description: 
write here
# -----------------------------------------------------------------------------------------------------
"""
from tkinter import *


def frame(root, side=TOP, **extras):
    widget = Frame(root)
    widget.pack(side=side, expand=YES, fill=BOTH)
    if extras: widget.config(**extras)
    return widget


def label(root, side, text, **extras):
    widget = Label(root, text=text, relief=RIDGE)   # 默认配置
    widget.pack(side=side, expand=YES, fill=BOTH)   # 打包
    if extras:
        widget.config(**extras)                     # 应用任何关键字传参，如果关键字对的话
    return widget


def button(root, side, text, command, **extras):
    widget = Button(root, text=text, command=command)
    widget.pack(side=side, expand=YES, fill=BOTH)
    if extras: widget.config(**extras)
    return widget


def entry(root, side, linkvar, **extras):
    widget = Entry(root, relief=SUNKEN, textvariable=linkvar)
    widget.pack(side=side, expand=YES, fill=BOTH)
    if extras: widget.config(**extras)
    return widget


if __name__ == '__main__':
    app = Tk()
    frm = frame(app, TOP)
    label(frm, LEFT, 'SPAM')
    button(frm, BOTTOM, 'Press', lambda: print('Pushed'))
    mainloop()
